import yaml


class MgtYaml:
    def __init__(self, yaml_file):
        self.file = yaml_file

    def read_yaml(self):
        with open(self.file, encoding="utf-8") as file_obj:
            yaml_data = yaml.safe_load(file_obj)
        return yaml_data

    def get_func_data(self, mokuai):
        return self.read_yaml().get(mokuai)

    def get_yaml_data(self, mokuai, level):
        # test_datas = self.read_yaml()[mokuai][level]["datas"]
        # case_ids = self.read_yaml()[mokuai][level]["ids"]
        test_datas = self.read_yaml().get(mokuai).get(level).get("data")
        case_ids = self.read_yaml().get(mokuai).get(level).get("ids")
        return test_datas, case_ids

    def get_test_data(self, mokuai, level):
        return self.read_yaml().get(mokuai).get(level).get("data")

    def get_case_ids(self, mokuai, level):
        return self.read_yaml().get(mokuai).get(level).get("ids")


if __name__ == '__main__':
    test_data = MgtYaml("../docs/测试数据/hero_test_data.yaml")
    print(test_data.get_func_data("add")["L1"]["data"])
    # print(test_data.get_test_data("add", "L1"))
    # print(test_data.get_case_ids("add", "L1"))
